package com.mk.car.dao;

import org.junit.Test;
import org.nutz.dao.Cnd;
import org.nutz.dao.util.cri.SqlExpression;
import com.mk.common.util.StringUtils;


public class CndDemo {
	
	@Test
	public void test1() {
		Cnd cnd = Cnd.where("(PLAN_MONTH", "IS", null);
		cnd.wrap(")");
		
		System.out.println(cnd); // WHERE (PLAN_MONTH IS NULL 
	}
	
	@Test
	public void test2() {
		SqlExpression sqlExpression = Cnd.exp("(PLAN_MONTH", "IS", null);
//		System.out.println(sqlExpression); //org.nutz.dao.util.cri.IsNull@1b40d5f0
		
		System.out.println(sqlExpression.toString());//org.nutz.dao.util.cri.IsNull@1b40d5f0
	}
	
	@Test
	public void test3() {
		Cnd cnd = Cnd.where(null);
		SqlExpression sqlExpression = Cnd.exp("(PLAN_MONTH", "IS", null);
		cnd.and(sqlExpression);
		
		System.out.println(cnd.toString());//WHERE (PLAN_MONTH IS NULL 
	}
	
	@Test
	public void test4() {
//		String planMonth = "202002";
		String planMonth = "";
		Cnd cnd = Cnd.where("regionId","=","301105000000");

		cnd.and(Cnd.exps("PLAN_MONTH", "IS", null).orEX("PLAN_MONTH", "=", planMonth));
		System.out.println(cnd); //WHERE regionId='301105000000' AND (PLAN_MONTH IS NULL )
	}
	
	@Test
	public void test5() {
		Cnd cnd = Cnd.where("(PLAN_MONTH","IS",null+")");
		
		System.out.println(cnd); //WHERE (PLAN_MONTH IS 'null)'
	}
	@Test
	public void test6() {
		Cnd cnd = Cnd.where("(PLAN_MONTH","IS","NULL)");
		
		System.out.println(cnd); //WHERE (PLAN_MONTH IS 'NULL)'
	}
	
	@Test
	public void test7() {
//		String planMonth = "202002";
		String planMonth = null;
		Cnd cnd = Cnd.where("regionId","=","301105000000");

		cnd.and("PLAN_MONTH", "=", planMonth);
		System.out.println(cnd); //WHERE regionId='301105000000' AND PLAN_MONTH IS NULL
	}
	
	
	@Test
	public void test8() {
		System.out.println(StringUtils.isEmpty("  ") );
	}
	
	
	public static void main(String[] args) {
		
	}
	
}
